package org.example.greenhouse.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.example.greenhouse.entity.User;
import org.example.greenhouse.result.Result;
import org.example.greenhouse.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@CrossOrigin
@RestController
@Api (tags = "用户")
@RequestMapping("/User")
public class UserController {
    @Autowired
    private UserService userService;

    @PostMapping("/register")
    @ApiOperation("注册")
    public Result register(@RequestBody User user) {
        return userService.register(user); // 注册
    }

    @PostMapping("/login")
    @ApiOperation("登陆")
    public Result login(@RequestParam String account, @RequestParam String password) {
        return userService.login(account, password); // 登录
    }
}